package com.gary.demo.common.utils;

import com.alibaba.excel.util.StringUtils;
import com.gary.demo.common.exception.BizException;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collection;

public class CheckUtil {

    private final static String DEFAULT_ERROR_CODE = "500";

    public static void isNull(Object obj, String message) {

        if (obj == null) {
            throw new BizException(DEFAULT_ERROR_CODE, message);
        }

    }

    public static void isBlank(String str, String message) {
        if (StringUtils.isBlank(str)) {
            throw new BizException(DEFAULT_ERROR_CODE, message);
        }
    }

    public static void isEmpty(Collection collection, String message) {
        if (CollectionUtils.isEmpty(collection)) {
            throw new BizException(DEFAULT_ERROR_CODE, message);
        }
    }
}
